(function (window, document) {
  function resize () {
    var ww = window.innerWidth
    if (ww > window.screen.width) {
      window.requestAnimationFrame(resize)
    } else {
      // var ua = navigator.userAgent.toLowerCase()
      // if (/iphone|ipad|ipod/.test(ua)) {
      // var sc = 1 / window.devicePixelRatio
      // document.getElementsByName('viewport')[0].content = `initial-scale=${sc}, maximum-scale=${sc}, minimum-scale=${sc}, user-scalable=no`
      // }
      // 设计宽度
      var designWidth = 750
      var rem2px = 100
      var d = window.document.createElement('div')
      d.id = 'responsive'
      d.style.width = '1rem'
      d.style.display = 'none'
      var head = window.document.getElementsByTagName('head')[0]
      head.appendChild(d)
      window.defaultFontSize = parseFloat(window.getComputedStyle(d, null).getPropertyValue('width'))
      // d.remove()
      document.documentElement.style.fontSize =
        window.innerWidth / designWidth * rem2px / window.defaultFontSize * 100 + '%'
      window.defaultFontSize = parseFloat(window.getComputedStyle(d, null).getPropertyValue('width').replace(/px/, ''))
    }
  }
  if (document.readyState !== 'loading') {
    resize()
  } else {
    document.addEventListener('DOMContentLoaded', resize)
  }
  // window.addEventListener('resize', resize)
})(window, document)
